/*=============================================================================
# FileName    :	axi_stream_drive.svh
# Author      :	author
# Email       :	email@email.com
# Description :	
# Version     :	1.0
# LastChange  :	2018-09-17 17:00:54
# ChangeLog   :	
=============================================================================*/

`ifndef AXI_STREAM_DRIVE_H
`define AXI_STREAM_DRIVE_H

class axi_stream_drive;
    virtual axi_stream_bfm    bfm;
    /*
     * 静态属性
     */
    function new(virtual axi_stream_bfm b);  // 需要赋初值的属性
        bfm = b;
    endfunction

    /*-------------------------------------------------------------------------
    //description   :   
    -------------------------------------------------------------------------*/
    extern task write_random_frame(int len);
    /*-------------------------------------------------------------------------
    //description   :   依次发送0-255
    -------------------------------------------------------------------------*/
    extern task write_standard_frame();
endclass

task axi_stream_drive::write_random_frame(int len);
    @ (posedge bfm.aclk);
    bfm.m_axis_tvalid = 1;
    for(int i = 0; i < len - 1; i = i + 1 )
    begin
        bfm.m_axis_tdata = $urandom_range(0, 255);
        @ (posedge bfm.aclk);
    end
    bfm.m_axis_tlast = 1;
    bfm.m_axis_tdata = $urandom_range(0, 255);
    @ (posedge bfm.aclk);
    bfm.m_axis_tvalid = 0;
    bfm.m_axis_tlast = 0;
    bfm.m_axis_tdata = 0;
endtask

task axi_stream_drive::write_standard_frame();
    @ (posedge bfm.aclk);
    bfm.m_axis_tvalid = 1;
    for(bit [7:0] i = 0; i < 255; i = i + 1 )
    begin
        bfm.m_axis_tdata = {i+3, i+2, i+1, i};
        @ (posedge bfm.aclk);
    end
    bfm.m_axis_tlast = 1;
    bfm.m_axis_tdata = 32'hFFFFFFFF;
    @ (posedge bfm.aclk);
    bfm.m_axis_tvalid = 0;
    bfm.m_axis_tlast = 0;
    bfm.m_axis_tdata = 0;
endtask
`endif
